package com.neutech.neurfin.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.neutech.neurfin.service.FinService;
import com.neutech.po.Conts;
import com.neutech.po.Fin;

@RestController
@RequestMapping("/his/fin")
public class FinController {

	@Autowired
	private FinService finService;

	@RequestMapping("/getDeleteFin")
	public Fin getDeleteUser(int id) throws Exception{
		Fin fin = finService.deleteFin(id);
		return fin;
	}
		
	@RequestMapping(value="/getUpdateFin",method=RequestMethod.POST)
	public Fin getUpdateUser(Fin fin) throws Exception{
		fin = finService.updateFin(fin);
		return fin;
	}
	@RequestMapping(value="/getInsertFin",method=RequestMethod.POST)
	public Fin getInsertUser(Fin fin) throws Exception{
		fin = finService.insertFin(fin);
		return fin;
	}
	
	@RequestMapping("/getSelectfin")
	public Fin getUser(Integer id) throws Exception{
		Fin fin = finService.findFin(id);
		return fin;
	}
	
	@RequestMapping(value="/add",method=RequestMethod.POST)
	public String addNewConts(Conts conts) throws Exception{
		int result = finService.addConts(conts);
		if(result == 1){
			return "success";
			
		}else{
			return "error";
		}
	}
	
	@RequestMapping("/selectConstant")
	public List<Conts> toNewConstant() throws Exception{
		return finService.getConstantAll();	
	}

}
